﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace photogalleryMVC
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            
            routes.MapRoute(null, "Account/{action}", new { controller = "Account" });
            //route to add photo
            routes.MapRoute(null, "AddPhotoInAlbum/{albumId}", new {controller = "Photo", action = "AddPhoto"});

            //route to add album
            routes.MapRoute(null, "CreateAlbumIn/{parentAlbumId}", new {controller = "Album", action = "Create"});
            
            routes.MapRoute(null, "", new {controller = "Home", action = "Index"});

            routes.MapRoute(null, "Last", new {controller = "Photo", Action = "Last"});

            routes.MapRoute(null, "News", new { controller = "News", action = "Index" });

            routes.MapRoute(null, "Users/{action}", new {controller = "Users", action = "index"});

            routes.MapRoute(null, "ItemsOnPage", new {controller = "Album", action = "ItemsOnPage"});

            //routes to dislay photo  
           
            
            routes.MapRoute(
                "original", 
                "Original/{id}",
                new {controller="Photo",action="GetPhoto",photoType=PhotoGalleryEnteties.PhotoType.OriginalImage   }
                );
            routes.MapRoute(
               "optimized",
               "Optimized/{id}",
               new { controller = "Photo", action = "GetPhoto", photoType = PhotoGalleryEnteties.PhotoType.OptimizedImage  }
               ); 
            routes.MapRoute(
                "thumbnail",
                "Thumbnail/{id}",
                new { controller = "Photo", action = "GetPhoto", photoType = PhotoGalleryEnteties.PhotoType.ImageThumbnail  }
                );
           

            
            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index" } // Parameter defaults
            );
            
           
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }
    }
}